
import com.mysql.jdbc.Connection;
import com.mysql.jdbc.Statement;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.Socket;
import java.sql.DriverManager;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * HousingSelection.java
 *
 * Created on Oct 29, 2012, 4:45:36 PM
 */
/**
 *
 * @author WSMelnick
 */
public class HousingSelection extends javax.swing.JFrame
        {
     ObjectInputStream in;
     ObjectOutputStream out;
     ArrayList<Room> favRooms = new ArrayList<Room>();
    ArrayList<Room> availRooms = new ArrayList<Room>();
    int currentGroupIndex;
    int type;
    String typeString;
    String members;
    int loggedIn;
    
    
    /** Creates new form HousingSelection */
    public HousingSelection() {
        initComponents();
        connect();
        housingSelectionLoginDialog.setVisible(true);
        housingSelectionCompleteSelectionButton.setEnabled(false);
        housingSelectionFavoriteRoomsList.setListData(favRooms.toArray());
        
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        housingSelectionLoginDialog = new javax.swing.JDialog();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        housingSelectionLoginUsernameField = new javax.swing.JTextField();
        housingSelectionLoginPasswordField = new javax.swing.JPasswordField();
        housingSelectionLoginSubmitButton = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        selectionLabel = new javax.swing.JLabel();
        housingSelectionCurrentlySelectingLabel = new javax.swing.JLabel();
        housingSelectionRefreshButton = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        housingSelectionFavoriteRoomsList = new javax.swing.JList();
        jLabel5 = new javax.swing.JLabel();
        housingSelectionDormCombo = new javax.swing.JComboBox();
        jLabel6 = new javax.swing.JLabel();
        jSeparator1 = new javax.swing.JSeparator();
        jLabel7 = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        housingSelectionRoomList = new javax.swing.JList();
        housingSelectionStudentListLabel = new javax.swing.JLabel();
        housingSelectionMarkAsFavoriteButton = new javax.swing.JButton();
        housingSelectionLogOutButton = new javax.swing.JButton();
        housingSelectionCompleteSelectionButton = new javax.swing.JButton();

        housingSelectionLoginDialog.setAlwaysOnTop(true);
        housingSelectionLoginDialog.setSize(new java.awt.Dimension(361, 270));

        jLabel2.setText("Housing Selection Login");

        jLabel3.setText("Enter your group username:");

        jLabel4.setText("Enter your group password:");

        housingSelectionLoginSubmitButton.setText("Login");
        housingSelectionLoginSubmitButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                housingSelectionLoginSubmitButtonActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout housingSelectionLoginDialogLayout = new org.jdesktop.layout.GroupLayout(housingSelectionLoginDialog.getContentPane());
        housingSelectionLoginDialog.getContentPane().setLayout(housingSelectionLoginDialogLayout);
        housingSelectionLoginDialogLayout.setHorizontalGroup(
            housingSelectionLoginDialogLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, housingSelectionLoginDialogLayout.createSequentialGroup()
                .addContainerGap(92, Short.MAX_VALUE)
                .add(jLabel2)
                .add(116, 116, 116))
            .add(housingSelectionLoginDialogLayout.createSequentialGroup()
                .add(36, 36, 36)
                .add(housingSelectionLoginDialogLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                    .add(housingSelectionLoginDialogLayout.createSequentialGroup()
                        .add(jLabel3)
                        .add(18, 18, 18)
                        .add(housingSelectionLoginUsernameField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 113, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(housingSelectionLoginDialogLayout.createSequentialGroup()
                        .add(jLabel4)
                        .add(18, 18, 18)
                        .add(housingSelectionLoginDialogLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(housingSelectionLoginSubmitButton)
                            .add(housingSelectionLoginPasswordField))))
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        housingSelectionLoginDialogLayout.setVerticalGroup(
            housingSelectionLoginDialogLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(housingSelectionLoginDialogLayout.createSequentialGroup()
                .addContainerGap()
                .add(jLabel2)
                .add(44, 44, 44)
                .add(housingSelectionLoginDialogLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel3)
                    .add(housingSelectionLoginUsernameField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(50, 50, 50)
                .add(housingSelectionLoginDialogLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel4)
                    .add(housingSelectionLoginPasswordField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(38, 38, 38)
                .add(housingSelectionLoginSubmitButton)
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jLabel1.setFont(new java.awt.Font("Lucida Grande", 1, 18));
        jLabel1.setText("Housing Selection");

        selectionLabel.setText("You are selecting a ---- room with lottery number --- for the following people:");

        housingSelectionCurrentlySelectingLabel.setText("Currently, their are ---- parties ahead of you in the housing selection");

        housingSelectionRefreshButton.setText("Refresh");
        housingSelectionRefreshButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                housingSelectionRefreshButtonActionPerformed(evt);
            }
        });

        housingSelectionFavoriteRoomsList.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        jScrollPane1.setViewportView(housingSelectionFavoriteRoomsList);

        jLabel5.setText("Your favorite rooms:");

        housingSelectionDormCombo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        housingSelectionDormCombo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                housingSelectionDormComboActionPerformed(evt);
            }
        });

        jLabel6.setText("Choose a dorm:");

        jLabel7.setText("Select an available ---- room within ----:");

        housingSelectionRoomList.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        jScrollPane2.setViewportView(housingSelectionRoomList);

        housingSelectionStudentListLabel.setText("----,----,----,----");

        housingSelectionMarkAsFavoriteButton.setText("Mark as favorite");
        housingSelectionMarkAsFavoriteButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                housingSelectionMarkAsFavoriteButtonActionPerformed(evt);
            }
        });

        housingSelectionLogOutButton.setText("Log Out");
        housingSelectionLogOutButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                housingSelectionLogOutButtonActionPerformed(evt);
            }
        });

        housingSelectionCompleteSelectionButton.setText("Complete Selection (--- seconds remaining)");
        housingSelectionCompleteSelectionButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                housingSelectionCompleteSelectionButtonActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(layout.createSequentialGroup()
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
                                .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
                                    .addContainerGap()
                                    .add(housingSelectionCompleteSelectionButton, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
                                    .add(29, 29, 29)
                                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                                        .add(layout.createSequentialGroup()
                                            .add(jLabel6)
                                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                            .add(housingSelectionDormCombo, 0, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                        .add(jLabel7, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .add(jScrollPane2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 377, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))))
                            .add(layout.createSequentialGroup()
                                .addContainerGap()
                                .add(housingSelectionMarkAsFavoriteButton)))
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 280, Short.MAX_VALUE)
                        .add(housingSelectionLogOutButton))
                    .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
                        .addContainerGap()
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                            .add(jSeparator1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 760, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(layout.createSequentialGroup()
                                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                    .add(layout.createSequentialGroup()
                                        .add(jLabel1)
                                        .add(18, 18, 18)
                                        .add(housingSelectionRefreshButton))
                                    .add(housingSelectionStudentListLabel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 419, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                    .add(selectionLabel)
                                    .add(housingSelectionCurrentlySelectingLabel))
                                .add(45, 45, 45)
                                .add(jScrollPane1)))))
                .add(463, 463, 463))
            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                .addContainerGap(585, Short.MAX_VALUE)
                .add(jLabel5)
                .add(529, 529, 529))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                        .add(44, 44, 44)
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(jLabel1)
                            .add(housingSelectionRefreshButton))
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(selectionLabel)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(housingSelectionStudentListLabel)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 29, Short.MAX_VALUE)
                        .add(housingSelectionCurrentlySelectingLabel))
                    .add(layout.createSequentialGroup()
                        .addContainerGap()
                        .add(jLabel5)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 123, Short.MAX_VALUE)))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jSeparator1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 10, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(18, 18, 18)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel6)
                    .add(housingSelectionDormCombo, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(18, 18, 18)
                .add(jLabel7)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                .add(jScrollPane2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 176, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(18, 18, 18)
                .add(housingSelectionMarkAsFavoriteButton)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(housingSelectionCompleteSelectionButton)
                    .add(housingSelectionLogOutButton))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void housingSelectionRefreshButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_housingSelectionRefreshButtonActionPerformed
refresh();
    }//GEN-LAST:event_housingSelectionRefreshButtonActionPerformed

    private void housingSelectionMarkAsFavoriteButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_housingSelectionMarkAsFavoriteButtonActionPerformed
favRooms.add(availRooms.get(housingSelectionRoomList.getSelectedIndex()));
housingSelectionFavoriteRoomsList.setListData(favRooms.toArray());
    }//GEN-LAST:event_housingSelectionMarkAsFavoriteButtonActionPerformed

    private void housingSelectionDormComboActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_housingSelectionDormComboActionPerformed
/*public ArrayList<Room> filterByBuilding(ArrayList<Room> list,int buildingID){
    ArrayList<Room> filtered = new ArrayList<Room>();
    
    for(int i =0; i < list.size(); i++){
        if(list.get(i).buildingID == buildingID)
            filtered.add(list.get(i));
    }
    
    return filtered;
    
    
}
*/
    }//GEN-LAST:event_housingSelectionDormComboActionPerformed

    private void housingSelectionLoginSubmitButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_housingSelectionLoginSubmitButtonActionPerformed
startSelection();
        
    }//GEN-LAST:event_housingSelectionLoginSubmitButtonActionPerformed

    private void housingSelectionCompleteSelectionButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_housingSelectionCompleteSelectionButtonActionPerformed
makeSelection();    }//GEN-LAST:event_housingSelectionCompleteSelectionButtonActionPerformed

    private void housingSelectionLogOutButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_housingSelectionLogOutButtonActionPerformed
favRooms.clear();
currentGroupIndex=0;
    }//GEN-LAST:event_housingSelectionLogOutButtonActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(HousingSelection.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(HousingSelection.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(HousingSelection.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(HousingSelection.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new HousingSelection().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton housingSelectionCompleteSelectionButton;
    private javax.swing.JLabel housingSelectionCurrentlySelectingLabel;
    private javax.swing.JComboBox housingSelectionDormCombo;
    private javax.swing.JList housingSelectionFavoriteRoomsList;
    private javax.swing.JButton housingSelectionLogOutButton;
    private javax.swing.JDialog housingSelectionLoginDialog;
    private javax.swing.JPasswordField housingSelectionLoginPasswordField;
    private javax.swing.JButton housingSelectionLoginSubmitButton;
    private javax.swing.JTextField housingSelectionLoginUsernameField;
    private javax.swing.JButton housingSelectionMarkAsFavoriteButton;
    private javax.swing.JButton housingSelectionRefreshButton;
    private javax.swing.JList housingSelectionRoomList;
    private javax.swing.JLabel housingSelectionStudentListLabel;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JLabel selectionLabel;
    // End of variables declaration//GEN-END:variables

   
    public void refresh()
    {
        try {
            out.writeInt(2);
            currentGroupIndex = in.readInt();
            out.writeInt(3);
            try {
                availRooms = (ArrayList<Room>) in.readObject();
                            out.flush();

            } catch (ClassNotFoundException ex) {
                Logger.getLogger(HousingSelection.class.getName()).log(Level.SEVERE, null, ex);
            }
            
        } catch (IOException ex) {Logger.getLogger(HousingSelection.class.getName()).log(Level.SEVERE, null, ex);
}
            
        housingSelectionRoomList.setListData(availRooms.toArray());
        housingSelectionCurrentlySelectingLabel.setText("Currently, their are " + currentGroupIndex + " parties ahead of you in the housing selection");
        if (currentGroupIndex == 0){
            JOptionPane.showMessageDialog(this, "IT IS NOW YOUR TURN TO SELECT A ROOM. PLEASE CHOOSE AS QUICKLY AS POSSIBLE.");
            housingSelectionCompleteSelectionButton.setEnabled(true);
        }
        //how to update favorite rooms list so that rooms no longer in available rooms list disappear?
     //   if (
    }
public void startSelection() {
        try {
            //log in
            out.writeInt(1);
            out.writeObject(housingSelectionLoginUsernameField.getText());
            out.writeObject(String.valueOf(housingSelectionLoginPasswordField.getPassword()));
            loggedIn = in.readInt();
            
            if (loggedIn ==1) {
            JOptionPane.showMessageDialog(this, "You have logged in sucessfully");
            housingSelectionLoginDialog.setVisible(false);

            out.writeInt(7);
                try {
                    members = in.readObject().toString();
                } catch (IOException ex) {
                    Logger.getLogger(HousingSelection.class.getName()).log(Level.SEVERE, null, ex);
                } catch (ClassNotFoundException ex) {
                    Logger.getLogger(HousingSelection.class.getName()).log(Level.SEVERE, null, ex);
                }
             
             getType();
             setLabels();
             refresh();

            } else if (loggedIn == 0){
            JOptionPane.showMessageDialog(this, "You have entered an incorrect username or password. Please try again.");
            }
            
         //   out.flush();
            
       } catch (IOException e) {
            shutDown();
            System.out.println("Log in error");
        }
        
       

    }
 public void connect() {
        try {
            Socket s = new Socket("localhost", 8000);
            in = new ObjectInputStream(s.getInputStream());
            out = new ObjectOutputStream(s.getOutputStream());
        } catch (IOException e) {
            shutDown();
        }
    }

    private void shutDown() {
        try {
            out.writeInt(6);
            out.flush();
            out.close();
            in.close();
        } catch (IOException ex) {
            Logger.getLogger(HousingSelection.class.getName()).log(Level.SEVERE, null, ex);
           
        }

    }

    private void makeSelection() {
        if(JOptionPane.showConfirmDialog(null, "Are you sure you want to select this room?") == JOptionPane.YES_OPTION){
        
        try {
            out.writeInt(4);
            out.writeObject(housingSelectionFavoriteRoomsList.getSelectedValue());
            out.flush();
        } catch (IOException ex) {
            Logger.getLogger(HousingSelection.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
        JOptionPane.showMessageDialog(this, "You have sucessfully choosen your room!");
        shutDown();
    }

    private void getType() {
        try {
            out.writeInt(5);
            type = in.readInt();
        } catch (IOException ex) {
            Logger.getLogger(HousingSelection.class.getName()).log(Level.SEVERE, null, ex);
        }
        switch(type){
            case 0:
                typeString = "Single";
                break;
            case 1:
                typeString = "Double";
                break;
            case 2:
                typeString = "Triple";
                break;
            case 3:
                typeString = "Quad";
                break;
        }
    }
    private void setLabels(){
    selectionLabel.setText("You are selecting a " + typeString + " room for the following people:");
    housingSelectionStudentListLabel.setText(members);
    
    }
}
